<template>
  <div class="testApp">
    <top></top>
    <div v-show="show===true" class="head">
      <div>
        <step :index="currentIndex" id="1" name="邮箱验证"></step>
        <span class="border" :class="{ downborder: currentIndex > 1 }"></span>

        <step :index="currentIndex" id="2" name="设置新密码"></step>
        <span class="border" :class="{ downborder: currentIndex > 2 }"></span>

        <step :index="currentIndex" id="3" name="完成"></step>
      </div>
    </div>

    <div v-if="show===true" class="btn">
      <step-1 @next="next" v-if="currentIndex === 1"></step-1>
      <step-2 @next="next" v-if="currentIndex === 2"></step-2>
      <step-3 @next="next" v-if="currentIndex === 3"></step-3>
    </div>
    <div v-else class="btn">
          <div class="content">
      <div class="pic">
        <img src="@/assets/error.png" alt="">
      </div>
      <h2>链接已失效</h2>
      <!-- <div class="next" @click="next">确定</div> -->
    </div>
    </div>

  </div>
</template>

<script>
import step from '../../components/step.vue'
import step1 from './components/step1.vue'
import step2 from './components/step2.vue'
import step3 from './components/step3.vue'

import top from './components/top.vue'

export default {
  components: {
    step,
    step1,
    step2,
    step3,

    top
  },
  created () {
    this.currentIndex = 1
    // console.log(this.$route.query.email)
    const email = this.$route.query.email
    sessionStorage.setItem('email', email)
    this.$store.dispatch('user/emailVerifyData', email).then(res => {
      this.show = true
    }).catch(res => {
      this.show = false
    })
  },
  data () {
    return {
      currentIndex: Number(window.sessionStorage.getItem('index2')) || 1,
      arr: [],
      show: false
    }
  },
  methods: {
    next () {
      var index = ++this.currentIndex
      // // console.log(index)
      if (index >= 3) {
        index = 1
      }
      window.sessionStorage.setItem('index2', index)
    }
  }
}
</script>

<style lang="scss" scoped>
.testApp {
  width: 100%;
  min-height: 1080px;
  position: relative;

  background-color: #f2f4f8;
  overflow: hidden;
  .head {
    width: 1440px;
    height: 44px;
    line-height: 44px;
    margin: 30px auto;
    text-align: center;
    .border {
      display: inline-block;
      width: 264px;
      height: 1px;
      background: #ccc;
      vertical-align: middle;
      margin-right: 12px;
    }
    .downborder {
      background: #304eec;
    }
  }
  .btn {
    width: 1440px;
    height: 830px;
    opacity: 1;
    position: absolute;
    background: #ffffff;
    top: 160px;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
  }
    .content {
      display: inline-block;
    .pic {
      width: 64px;
      height: 64px;
      margin-top: 128px;
      display: inline-block;
      img{
        width: 100%;
      }

    }
    h2 {
      margin-top: 25px;
      font-size: 20px;
      font-weight: 600;
      color: #1b1f35;
      margin-bottom: 60px;
    }
    .next {
      display: inline-block;
      width: 360px;
      height: 44px;
      opacity: 1;
      background: #304eec;
      border-radius: 4px;
      line-height: 44px;
      color: #ffffff;
      text-align: center;
    }
  }
}
</style>
